using UnityEngine;

namespace Coffee.UIExtensions
{
    // [Assembly-CSharp.dll].Coffee.UIExtensions.UIShadow
    public class UIShadow : Shadow, IParameterTexture
    {
        
        #region Coffee.UIExtensions.UIShadow.AdditionalShadow
        // [Assembly-CSharp.dll].Coffee.UIExtensions.UIShadow.AdditionalShadow
        [Serializable]
        public class AdditionalShadow
        {
            // Fields
            public float blur;
            public Coffee.UIExtensions.ShadowStyle style;
            public UnityEngine.Color effectColor;
            public UnityEngine.Vector2 effectDistance;
            public bool useGraphicAlpha;
            
            // Methods
            public AdditionalShadow()
            {
                this.blur = 0.25f;
                this.style = 1;
                this.effectColor = ;
                this.effectDistance = -0.00781250184809323;
                this.useGraphicAlpha = true;
            }
        
        }
        
        #endregion
        
        // Fields
        private float m_BlurFactor;
        private Coffee.UIExtensions.ShadowStyle m_Style;
        private System.Collections.Generic.List<Coffee.UIExtensions.UIShadow.AdditionalShadow> m_AdditionalShadows;
        private int _parameterIndex_k__BackingField;
        private Coffee.UIExtensions.ParameterTexture _ptex_k__BackingField;
        private int _graphicVertexCount;
        private static readonly System.Collections.Generic.List<Coffee.UIExtensions.UIShadow> tmpShadows;
        private Coffee.UIExtensions.UIEffect _uiEffect;
        private static readonly System.Collections.Generic.List<UnityEngine.UIVertex> s_Verts;
        
        // Properties
        public float blur { get; set; }
        public float blurFactor { get; set; }
        public Coffee.UIExtensions.ShadowStyle style { get; set; }
        public int parameterIndex { get; set; }
        public Coffee.UIExtensions.ParameterTexture ptex { get; set; }
        
        // Methods
        public float get_blur()
        {
            return (float)this.m_BlurFactor;
        }
        public void set_blur(float value)
        {
            this.m_BlurFactor = (value >= 0) ? value : 0f;
            this._SetDirty();
        }
        public float get_blurFactor()
        {
            return (float)this.m_BlurFactor;
        }
        public void set_blurFactor(float value)
        {
            this.m_BlurFactor = (value >= 0) ? value : 0f;
            this._SetDirty();
        }
        public Coffee.UIExtensions.ShadowStyle get_style()
        {
            return (Coffee.UIExtensions.ShadowStyle)this.m_Style;
        }
        public void set_style(Coffee.UIExtensions.ShadowStyle value)
        {
            this.m_Style = value;
            this._SetDirty();
        }
        public int get_parameterIndex()
        {
            return (int)this._parameterIndex_k__BackingField;
        }
        public void set_parameterIndex(int value)
        {
            this._parameterIndex_k__BackingField = value;
        }
        public Coffee.UIExtensions.ParameterTexture get_ptex()
        {
            return (Coffee.UIExtensions.ParameterTexture)this._ptex_k__BackingField;
        }
        private void set_ptex(Coffee.UIExtensions.ParameterTexture value)
        {
            this._ptex_k__BackingField = value;
        }
        protected override void OnEnable()
        {
            this.OnEnable();
            this._uiEffect = this.GetComponent<System.Object>();
            if((UnityEngine.Object.op_Implicit(exists:  this._uiEffect)) == false)
            {
                    return;
            }
            
            this._ptex_k__BackingField = this._uiEffect;
            this._ptex_k__BackingField.Register(target:  this);
        }
        protected override void OnDisable()
        {
            this.OnDisable();
            this._uiEffect = 0;
            if(this._ptex_k__BackingField == null)
            {
                    return;
            }
            
            this._ptex_k__BackingField.Unregister(target:  this);
            this._ptex_k__BackingField = 0;
        }
        public override void ModifyMesh(UnityEngine.UI.VertexHelper vh)
        {
            var val_4;
            UnityEngine.Object val_5;
            var val_15;
            var val_16;
            UnityEngine.Object val_18;
            var val_19;
            var val_21;
            var val_22;
            var val_24;
            Coffee.UIExtensions.UIEffect val_25;
            var val_26;
            if(this.isActiveAndEnabled == false)
            {
                    return;
            }
            
            if(vh.currentVertCount < 1)
            {
                    return;
            }
            
            if(this.m_Style == 0)
            {
                    return;
            }
            
            val_16 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_16 = 536894869;
            }
            
            vh.GetUIVertexStream(stream:  mem[536895053] + 8);
            this.GetComponents<System.Object>(results:  mem[536895053]);
            System.Collections.Generic.List<T>.System.Collections.Generic.List.Enumerator<Unknown> val_3 = mem[536895053].GetEnumerator();
            label_20:
            val_18 = -1073678177;
            if(val_4.MoveNext() == false)
            {
                goto label_11;
            }
            
            if(val_5 == 0)
            {
                    throw new NullReferenceException();
            }
            
            if(val_5.isActiveAndEnabled == false)
            {
                goto label_20;
            }
            
            val_18 = this;
            if(val_5 != this)
            {
                goto label_11;
            }
            
            val_19 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_19 = 536894869;
            }
            
            if(mem[536895053] == 0)
            {
                    throw new NullReferenceException();
            }
            
            System.Collections.Generic.List<T>.System.Collections.Generic.List.Enumerator<Unknown> val_9 = mem[536895053].GetEnumerator();
            label_18:
            val_18 = -1073678177;
            if(val_4.MoveNext() == false)
            {
                goto label_14;
            }
            
            val_21 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_21 = 536894869;
            }
            
            if((mem[536895053] + 8) == 0)
            {
                    throw new NullReferenceException();
            }
            
            if(val_5 == 0)
            {
                    throw new NullReferenceException();
            }
            
            mem2[0] = mem[536895053] + 8 + 24;
            goto label_18;
            label_14:
            val_22 = 0;
            val_18 = -1073678179;
            val_4.Dispose();
            if(val_22 != 0)
            {
                    throw new NullReferenceException();
            }
            
            if(9 == 0)
            {
                goto label_20;
            }
            
            goto label_21;
            label_11:
            val_4.Dispose();
            label_60:
            val_24 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_24 = 536894869;
            }
            
            var val_14 = mem[536895053] + 24 + 4;
            val_14 = val_14 + 1;
            mem2[0] = 0;
            mem2[0] = val_14;
            if((mem[536895053] + 24) >= 1)
            {
                    System.Array.Clear(array:  mem[536895053] + 16, index:  0, length:  mem[536895053] + 24);
            }
            
            val_15 = this;
            val_25 = this._uiEffect;
            if(val_25 == null)
            {
                    val_25 = this.GetComponent<System.Object>();
            }
            
            this._uiEffect = val_25;
            val_26 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_26 = 536894869;
            }
            
            int val_15 = this._graphicVertexCount;
            val_15 = (mem[536895053] + 8 + 24) - val_15;
            if(this._ptex_k__BackingField != null)
            {
                    val_25 = 0;
                if((UnityEngine.Object.op_Implicit(exists:  this._uiEffect)) != false)
            {
                    val_25 = 0;
                if(this._uiEffect.isActiveAndEnabled != false)
            {
                    this._ptex_k__BackingField.SetData(target:  this, channelId:  0, value:  this._uiEffect.m_EffectFactor);
                this._ptex_k__BackingField.SetData(target:  this, channelId:  1, value:  255);
                val_25 = this;
                this._ptex_k__BackingField.SetData(target:  this, channelId:  2, value:  this.m_BlurFactor);
            }
            
            }
            
            }
            
            this._ApplyShadow(verts:  this, color:  new UnityEngine.Color() {r = this.m_BlurFactor}, start:  323570892, end:  323570888, effectDistance:  new UnityEngine.Vector2(), style:  null, useGraphicAlpha:  false);
            vh.Clear();
            vh.AddUIVertexTriangleStream(verts:  mem[536895053] + 8);
            var val_16 = mem[536895053] + 8 + 28;
            val_16 = val_16 + 1;
            mem2[0] = 0;
            mem2[0] = val_16;
            return;
            label_21:
            val_4.Dispose();
            if(9 == 9)
            {
                goto label_60;
            }
        
        }
        private void _ApplyShadow(System.Collections.Generic.List<UnityEngine.UIVertex> verts, UnityEngine.Color color, int start, int end, UnityEngine.Vector2 effectDistance, Coffee.UIExtensions.ShadowStyle style, bool useGraphicAlpha)
        {
            var val_2;
            var val_3;
            var val_4;
            bool val_5;
            var val_6;
            float val_7;
            System.Collections.Generic.List<UnityEngine.UIVertex> val_8;
            var val_9;
            if(color.a <= 0f)
            {
                    return;
            }
            
            if(effectDistance == 0)
            {
                    return;
            }
            
            val_2 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_2 = 536894869;
            }
            
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  V4.16B, y:  V5.16B, useGraphicAlpha:  style & 1);
            if(effectDistance == 2)
            {
                goto label_4;
            }
            
            if(effectDistance == 3)
            {
                goto label_5;
            }
            
            if(effectDistance != 4)
            {
                    return;
            }
            
            val_3 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_3 = 536894869;
            }
            
            val_4 = mem[536895053];
            val_5 = style & 1;
            goto label_8;
            label_4:
            val_6 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_6 = 536894869;
            }
            
            val_7 = -V5.16B;
            val_5 = style & 1;
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  V4.16B, y:  val_7, useGraphicAlpha:  val_5);
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  -V4.16B, y:  V5.16B, useGraphicAlpha:  val_5);
            val_8 = mem[mem[536895053] + 8];
            val_8 = mem[536895053] + 8;
            goto label_10;
            label_5:
            val_9 = 536894869;
            if(mem[536895093] == 0)
            {
                    val_9 = 536894869;
            }
            
            val_7 = -V5.16B;
            val_5 = style & 1;
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  V4.16B, y:  val_7, useGraphicAlpha:  val_5);
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  -V4.16B, y:  V5.16B, useGraphicAlpha:  val_5);
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  -V4.16B, y:  val_7, useGraphicAlpha:  val_5);
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  -V4.16B, y:  0f, useGraphicAlpha:  val_5);
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  0f, y:  val_7, useGraphicAlpha:  val_5);
            val_4 = mem[536895053];
            label_8:
            this._ApplyShadowZeroAlloc(verts:  mem[536895053] + 8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  V4.16B, y:  0f, useGraphicAlpha:  val_5);
            val_8 = mem[mem[536895053] + 8];
            val_8 = mem[536895053] + 8;
            label_10:
            this._ApplyShadowZeroAlloc(verts:  val_8, color:  new UnityEngine.Color() {r = color.r, g = color.g, b = color.b, a = color.a}, start:  start, end:  end, x:  0f, y:  V5.16B, useGraphicAlpha:  val_5);
        }
        private void _ApplyShadowZeroAlloc(System.Collections.Generic.List<UnityEngine.UIVertex> verts, UnityEngine.Color color, int start, int end, float x, float y, bool useGraphicAlpha)
        {
            var val_8;
            int val_38;
            var val_40;
            var val_41;
            float val_42;
            var val_43;
            float val_44;
            var val_45;
            var val_47;
            float val_48;
            var val_49;
            var val_51;
            float val_52;
            var val_53;
            var val_55;
            float val_56;
            var val_57;
            val_38 = mem[end];
            val_38 = end;
            int val_1 = val_38 - start;
            int val_2 = start + val_1;
            if(verts.Capacity < val_2)
            {
                    verts.Capacity = val_2;
            }
            
            if((this._ptex_k__BackingField != null) && ((UnityEngine.Object.op_Implicit(exists:  this._uiEffect)) != false))
            {
                    if(this._uiEffect.isActiveAndEnabled != false)
            {
                    float val_6 = this._ptex_k__BackingField.GetNormalizedIndex(target:  this);
            }
            
            }
            
            if(val_1 >= 1)
            {
                    val_38 = 108;
                var val_31 = val_1;
                do
            {
                var val_7 = W10 + 1;
                mem2[0] = val_7;
                if(val_7 < val_8)
            {
                    var val_10 = 323570784 + (val_7 * 108);
                mem2[0] = val_7 + 1;
                mem2[0] = 0;
                mem2[0] = 0;
                mem2[0] = 0;
                mem2[0] = 0;
                mem2[0] = 0;
                mem2[0] = 0;
                mem2[0] = 0;
                mem2[0] = 0;
                mem2[0] = 0;
                mem2[0] = 0;
            }
            else
            {
                    val_8 = 0;
            }
            
                val_31 = val_31 - 1;
            }
            while(val_7 != val_8);
            
            }
            
            val_41 = 27393328;
            int val_11 = (mem[3221259503] + 192) - 1;
            if(val_11 >= val_1)
            {
                    val_38 = start - val_38;
                do
            {
                Unknown val_13 = verts.Item[val_38 + val_11];
                val_40 = -1073707725;
                verts.set_Item(index:  val_11, value:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, normal = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, tangent = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv1 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv2 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv3 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}});
                val_11 = val_11 - 1;
            }
            while(val_11 >= val_1);
            
            }
            
            if(val_1 < 1)
            {
                goto label_16;
            }
            
            var val_41 = 0;
            val_40 = 1132396544;
            label_42:
            Unknown val_16 = verts.Item[(val_1 + val_41) + start];
            float val_37 = 0f;
            val_42 = color.a;
            if(useGraphicAlpha != false)
            {
                    float val_32 = 0f;
                val_32 = color.a * val_32;
                val_42 = val_32 / 255f;
            }
            
            val_32 = val_32 * 255f;
            float val_17 = (mem[1152921504930430432] >= 0) ? (val_32) : 0f;
            if(val_17 >= 0f)
            {
                goto label_18;
            }
            
            if((double)val_17 != (-0.5))
            {
                goto label_19;
            }
            
            val_43 = 0;
            val_44 = (float)0f;
            val_45 = val_44 + (-1f);
            goto label_20;
            label_18:
            if((double)val_17 != 0.5)
            {
                goto label_21;
            }
            
            val_43 = 0;
            val_44 = (float)0f;
            val_45 = val_44 + 1f;
            label_20:
            var val_18 = ((val_43 & (1.401298E-45f)) != 0) ? (val_44) : (val_45);
            goto label_23;
            label_19:
            float val_33 = -0.5f;
            val_33 = val_17 + val_33;
            goto label_23;
            label_21:
            float val_34 = 0.5f;
            val_34 = val_17 + val_34;
            label_23:
            val_34 = val_34 * 255f;
            float val_19 = (mem[1152921504930430436] >= 0) ? (val_34) : 0f;
            if(val_19 >= 0f)
            {
                goto label_24;
            }
            
            if((double)val_19 != (-0.5))
            {
                goto label_25;
            }
            
            val_47 = 0;
            val_48 = (float)0f;
            val_49 = val_48 + (-1f);
            goto label_26;
            label_24:
            if((double)val_19 != 0.5)
            {
                goto label_27;
            }
            
            val_47 = 0;
            val_48 = (float)0f;
            val_49 = val_48 + 1f;
            label_26:
            var val_20 = ((val_47 & (1.401298E-45f)) != 0) ? (val_48) : (val_49);
            goto label_29;
            label_25:
            float val_35 = -0.5f;
            val_35 = val_19 + val_35;
            goto label_29;
            label_27:
            float val_36 = 0.5f;
            val_36 = val_19 + val_36;
            label_29:
            val_36 = val_36 * 255f;
            float val_21 = (mem[1152921504930430440] >= 0) ? (val_36) : 0f;
            if(val_21 >= 0f)
            {
                goto label_30;
            }
            
            if((double)val_21 != (-0.5))
            {
                goto label_31;
            }
            
            val_51 = 0;
            val_52 = (float)0f;
            val_53 = val_52 + (-1f);
            goto label_32;
            label_30:
            if((double)val_21 != 0.5)
            {
                goto label_33;
            }
            
            val_51 = 0;
            val_52 = (float)0f;
            val_53 = val_52 + 1f;
            label_32:
            var val_22 = ((val_51 & (1.401298E-45f)) != 0) ? (val_52) : (val_53);
            goto label_35;
            label_31:
            val_52 = val_21 + (-0.5f);
            goto label_35;
            label_33:
            val_52 = val_21 + 0.5f;
            label_35:
            float val_38 = x;
            val_37 = val_37 + val_38;
            val_38 = val_38 * 255f;
            float val_23 = (val_42 >= 0) ? (val_38) : 0f;
            if(val_23 >= 0f)
            {
                goto label_36;
            }
            
            if((double)val_23 != (-0.5))
            {
                goto label_37;
            }
            
            val_55 = 0;
            val_56 = (float)0f;
            val_57 = val_56 + (-1f);
            goto label_38;
            label_36:
            if((double)val_23 != 0.5)
            {
                goto label_39;
            }
            
            val_55 = 0;
            val_56 = (float)0f;
            val_57 = val_56 + 1f;
            label_38:
            val_56 = ((val_55 & (1.401298E-45f)) != 0) ? (val_56) : (val_57);
            goto label_41;
            label_37:
            float val_39 = -0.5f;
            val_39 = val_23 + val_39;
            goto label_41;
            label_39:
            float val_40 = 0.5f;
            val_40 = val_23 + val_40;
            label_41:
            byte val_25 = (val_19 < 0) ? ((int)val_19) : ((int)val_19);
            var val_26 = (val_21 < 0) ? ((int)val_21) : ((int)val_21);
            val_8 = 0;
            val_25 = val_25 & 255;
            val_26 = val_26 & 255;
            verts.set_Item(index:  0, value:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3() {x = val_37, y = 0f, z = 0f}, normal = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, tangent = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, color = new UnityEngine.Color32() {r = (val_17 < 0) ? ((int)val_17) : ((int)val_17), g = val_25, a = (val_40 < 0) ? ((int)val_40) : ((int)val_40)}, uv0 = new UnityEngine.Vector4() {x = 0f, y = (val_6 < 0f) ? 0f : (val_6), z = (val_6 < 0f) ? 0f : 0f, w = (val_6 < 0f) ? 0f : 0f}, uv1 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv2 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv3 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}});
            val_41 = val_41 + 1;
            val_41 = val_41;
            if(val_1 != val_41)
            {
                goto label_42;
            }
            
            label_16:
            mem2[0] = end;
            mem2[0] = end;
        }
        private void _SetDirty()
        {
            UnityEngine.Object val_8 = this.graphic;
            if((UnityEngine.Object.op_Implicit(exists:  val_8 = this.graphic)) == false)
            {
                    return;
            }
            
            UnityEngine.UI.Graphic val_3 = this.graphic;
            val_8 = ???;
            goto typeof(UnityEngine.UI.Graphic).__il2cppRuntimeField_2F8;
        }
        public UIShadow()
        {
            this.m_BlurFactor = 1f;
            this.m_Style = 1;
            System.Collections.Generic.List<System.Object> val_1 = 536903863;
            val_1 = new System.Collections.Generic.List<System.Object>();
            this.m_AdditionalShadows = val_1;
        }
        private static UIShadow()
        {
            System.Collections.Generic.List<System.Object> val_1 = 536903813;
            val_1 = new System.Collections.Generic.List<System.Object>();
            mem2[0] = val_1;
            System.Collections.Generic.List<UnityEngine.UIVertex> val_2 = 536877657;
            val_2 = new System.Collections.Generic.List<UnityEngine.UIVertex>();
            mem2[0] = val_2;
            throw new NullReferenceException();
        }
    
    }

}
